<?php

class CHelp extends Zend_Db_Table{
	
	protected $_name;
	
	protected $_primary;

	public function _setup(){
		
		$this->_name=R_PRE."helps";
		
		$this->_primary="helpid";
		
		parent::_setup();
		
	}

	public function createHelp($data){
		
		$helpid=$this->insert($data);
		
		return $helpid;
		
	}
	
	public function editHelp($itemid,$data){
		
		$db=$this->getAdapter();
		
		$where = $db->quoteInto('itemid = ?', $itemid);
		
		$rows_affected=$db->update($this->_name,$data,$where);
		
		if($rows_affected!=1){
			
			return false;
			
		}else{
			
			return true;
			
		}
		
		
	}
	
	public function getFenleiItems(){
		
		$db=$this->getAdapter();
		
		$thisArray=$db->fetchAll("SELECT ".R_PRE."helpfls.*,".R_PRE."items.* 
					FROM ".R_PRE."helpfls
					LEFT JOIN ".R_PRE."items ON ".R_PRE."items.flid=".R_PRE."helpfls.flid 
					WHERE item_type='help' 
					ORDER BY ".R_PRE."helpfls.flid ASC 
				  ");
					
		return $thisArray;
		
		
	}
	
	public function delHelps($itemidArray){
		
		$db=$this->getAdapter();
		
		$itemidString=join(',',$itemidArray);
		
		$result=$db->query("DELETE FROM $this->_name WHERE itemid IN ($itemidString)");
		
		return $result;
		
	}
	

	
}